import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex)
// 状态属性
const state = {
    userName: "test",
    rootTag: []
}

// 相当于计算属性，返回需要的值，第一个参数是satate
const getters = {
    getUserName: state => {
        return state.userName
    }
}

// 可用于异步处理，触发commit事件
const actions = {

}

// 同步处理事件
const mutations = {
    setUserName: (state, userName) => {
        state.userName = userName;
    }
}

export default new Vuex.Store({
    state,
    getters,
    actions,
    mutations
})